<?php 

/**
* 图片缩放处理的类
*/
class Zoom
{
	public $width=1000;		//画布宽度
	public $height=500;		//画布高度
	public $width_img;		//图片宽度
	public $height_img;		//图片高度
	public $want_w=500;		//想要图片缩放后的宽度
	public $want_h=250;		//想要图片缩放后的长度
	public $url="./car.png";	//图片路径

	function __construct($url="",$width="",$height="",$want_w="",$want_h="")
	{
		$this->url=empty($url)?$this->url:$url;
		$this->width=empty($width)?$this->width:$width;
		$this->height=empty($height)?$this->height:$height;
		$this->want_w=empty($want_w)?$this->want_w:$want_w;
		$this->want_h=empty($want_h)?$this->want_h:$want_h;

	}


	function run(){
		header("Content-type: image/png");
		$dst = imageCreateTrueColor($this->width,$this->height); //画布大小

		$src=imageCreateFrompng($this->url);    //打开外部图像

		$this->width_img=imagesx($src);//取得图像宽度

		$this->height_img=imagesy($src);//取得图像高度

		imagecopyresized($dst, $src, 0, 0, 0, 0, $this->want_w, $this->want_h, $this->width_img, $this->height_img) ;

		ob_clean() ; //清楚缓存
		imagepng($dst);

		


	}


















}


 ?>